package com.liujit.pay.wx.domain.params.refunds;

import cn.hutool.json.JSONObject;
import lombok.Builder;

/**
 * @description: 订单金额
 * @author: liujun
 * @create: 2021-02-20 09:39
 */
@Builder
public class RefundsAmount {

    /**
     * 退款金额
     */
    private Integer refund;

    /**
     * 原订单金额
     */
    private Integer total;

    /**
     * 初始化参数
     *
     * @param refund 退款金额
     * @param total  原订单金额
     * @return
     */
    public static RefundsAmount.Builder builder(Integer refund, Integer total) {
        return new RefundsAmount.Builder(refund, total);
    }

    public static class Builder {

        private Integer refund;
        private Integer total;

        Builder(Integer refund, Integer total) {
            this.refund = refund;
            this.total = total;
        }

        public RefundsAmount build() {
            return new RefundsAmount(this.refund, this.total);
        }
    }

    /**
     * 转化JSON字符串
     *
     * @return
     */
    public String toJSONString() {
        JSONObject json = new JSONObject();
        // 退款金额
        json.set("refund", refund);
        // 原订单金额
        json.set("total", total);
        // 货币类型
        json.set("currency", "CNY");
        return json.toString();
    }
}
